﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using LY.Interface;
using NLog;
using LY.Interface;

namespace LY.Business.ServiceImpl
{
    public class LogService : ILogService
    {
        /*
            logger.Trace("Sample trace message");
            logger.Debug("Sample debug message");
            logger.Info("Sample informational message");
            logger.Warn("Sample warning message");
            logger.Error("Sample error message");
            logger.Fatal("Sample fatal error message");

            // alternatively you can call the Log() method 
            // and pass log level as the parameter.
            logger.Log(LogLevel.Info, "Sample fatal error message");
        */
        private static Logger _logger = LogManager.GetLogger("LY");
        public void Trace(string msg)
        {
            _logger.Trace(msg);
        }
        public void Debug(string msg)
        {
            _logger.Debug(msg);
        }
        public void Info(string msg)
        {
            _logger.Info(msg);
        }

        public void Warn(string msg)
        {
            _logger.Warn(msg);
        }
        public void Error(string msg)
        {
            _logger.Error(msg);
        }
        public void Fatal(string msg)
        {
            _logger.Fatal(msg);
        }

        //*************LOG4NET*************//
        /// <summary>
        /// 输出日志到Log4Net

        //info
        public void WriteInfoLog(Type t, Exception ex)
        {
             log4net.ILog log = log4net.LogManager.GetLogger(t);
             log.Info("Info", ex);
        }
        //info
        public void WriteInfoLog(Type t, string msg)
        {
             log4net.ILog log = log4net.LogManager.GetLogger(t);
             log.Info(msg);
         }
        /// Error
        public void WriteErrorLog(Type t, Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Error("Error", ex);
        }
        ///Error
        public void WriteErrorLog(Type t, string msg)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Error(msg);
        }
        //Debug
        public void WriteDebugLog(Type t, Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Debug("Debug", ex);
        }
        //Debug
        public void WriteDebugLog(Type t, string msg)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Debug(msg);
        }
        //Warn
        public void WriteWarnLog(Type t, Exception ex)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Warn("Warn", ex);
        }
        //Warn
        public void WriteWarnLog(Type t, string msg)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(t);
            log.Warn(msg);
        }
    
    }
}
